-
Notifications
You must be signed in to change notification settings - Fork 182
fix: standardize logger names in core modules (phase 1) #902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: standardize logger names in core modules (phase 1) #902
Conversation
PR Review: #902 - Logger Standardization Phase 1Reviewer: Luca SummaryThis PR implements the first phase of logger standardization across core py-libp2p modules by replacing hardcoded logger names with Changes OverviewFiles Modified
Test Files Added
Detailed Analysis✅ Strengths
✅ Verification ResultsI verified the following aspects:
|
@PankajJaisu can you add a newsfragment ? |
Issue
Fix logging standardization in core modules (Phase 1)
Changes
logging.getLogger(__name__)
Testing
1. Unit Tests
Added comprehensive unit tests to verify logger functionality:
Results:
test_logger_names
: Verified all logger names are correcttest_loggers_exist_and_callable
: Confirmed loggers work without errors2. Module-Specific Logging Control
Network Module (Ping Example)
Observed logs:
libp2p.network.swarm
logger correctly outputs debug messagesPubSub Module Example
Observed logs:
libp2p.pubsub.gossipsub
logger correctly outputs debug messagesCombined Module Logging
3. Logger Name Verification
Output:
4. Basic Functionality Test
cd examples/ping/ python ping.py
Files Modified
Network & Host Modules
libp2p/network/swarm.py
:logging.getLogger("libp2p.network.swarm")
→logging.getLogger(__name__)
libp2p/host/basic_host.py
:logging.getLogger("libp2p.network.basic_host")
→logging.getLogger(__name__)
libp2p/transport/tcp/tcp.py
:logging.getLogger("libp2p.transport.tcp")
→logging.getLogger(__name__)
PubSub Modules
libp2p/pubsub/floodsub.py
:logging.getLogger("libp2p.pubsub.floodsub")
→logging.getLogger(__name__)
libp2p/pubsub/gossipsub.py
:logging.getLogger("libp2p.pubsub.gossipsub")
→logging.getLogger(__name__)
libp2p/pubsub/pubsub.py
:logging.getLogger("libp2p.pubsub")
→logging.getLogger(__name__)
libp2p/pubsub/validators.py
:logging.getLogger("libp2p.pubsub")
→logging.getLogger(__name__)
Verification Checklist
logging.getLogger(__name__)
LIBP2P_DEBUG
Learning
Working on this issue provided valuable insights into:
libp2p/utils/logging.py
enables module-specific control viaLIBP2P_DEBUG
__name__
: Automatic module path detection eliminates hardcoded strings and ensures consistencyImpact
After these changes, developers now have:
LIBP2P_DEBUG=network:DEBUG,pubsub:INFO
References